package com.lu.dog.dbrowser;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.webkit.WebView;

import com.lu.adog.base.BaseApp;
import com.lu.adog.base.BaseConfig;
import com.lu.adog.util.Logg;
import com.lu.adog.util.SharedPreferencesUtil;
import com.lu.dog.dbrowser.bean.IconInfo;
import com.lu.dog.dbrowser.db.DBrowserDbHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Yue
 * @date 2017/12/22 13:57
 */

public class App extends BaseApp {
    private static App INSTANCE;

    public static App getInstance() {
        return INSTANCE;
    }

    @Override
    public void onCreate() {
        INSTANCE = this;
        super.onCreate();
        init();

    }

    private void init() {

        SharedPreferences sharedPreferences = SharedPreferencesUtil.sharedPreferences(this, "config", Context.MODE_PRIVATE);
        boolean firstRun = sharedPreferences.getBoolean(BaseConfig.SP_KEY_FIRSTRUN, true);
        Logg.w(">>>", firstRun + "是否首次启动");
        if (firstRun) {
            sharedPreferences.edit().putBoolean(BaseConfig.SP_KEY_FIRSTRUN, false).commit();

            List<IconInfo> iconInfos = new ArrayList<>();
            long time = System.currentTimeMillis();
            iconInfos.add(new IconInfo(1, "http://m.baidu.com", "百度", null, null, time, time));
            iconInfos.add(new IconInfo(2, "http://m.58.com", "58同城", null, null, time, time));
            iconInfos.add(new IconInfo(3, "http://m.sogou.com", "搜狗", null, null, time, time));
            iconInfos.add(new IconInfo(4, "http://m.sui.taobao.org/demos/", "suiMobile", null, null, time, time));
            iconInfos.add(new IconInfo(5, "http://frozenui.github.io/frozenui/demo", "FrozenUI", null, null, time, time));
            iconInfos.add(new IconInfo(6, "https://h5.ele.me/msite", "饿了么", null, null, time, time));
            iconInfos.add(new IconInfo(7, "http://i.meituan.com", "美团", null, null, time, time));
            iconInfos.add(new IconInfo(8, "http://amazeui.org/showcase", "zmazeui案例", null, null, time, time));

            iconInfos.add(new IconInfo(8, "http://192.168.1.195:3100", "3100", null, null, time, time));
            iconInfos.add(new IconInfo(9, "http://192.168.1.195:3000", "3000", null, null, time, time));
            iconInfos.add(new IconInfo(10, "http://192.168.1.195:8080", "8080", null, null, time, time));

            DBrowserDbHelper.getInstance(this).updateIconInfo(iconInfos);
        }


    }

}
